
#include <BLight>
#include <BCamera>
#include <BCuller>

using namespace BWE;

class culler_member
{
public:
	culler_member()
	{

	}
	~culler_member()
	{

	}

	BSpace					space;
	BFrustum				frustum;
	BCameraHolder			camera;
	BLightList				lights;
	BNodeList				nodes;
};

#define member					(*(culler_member*)_ptr)
#define member_allocate()		_ptr = new culler_member
#define member_release()		delete (culler_member*)_ptr

BCuller::BCuller(BCamera* camera)
{
	member_allocate();
	member.camera = camera;
	//member.frustum = camera->frustum();
	member.space = member.frustum.space();
}
BCuller::~BCuller()
{
	member_release();
}

BCamera* BCuller::camera()
{
	return member.camera.ptr();
}
const BCamera* BCuller::camera() const
{
	return member.camera.ptr();
}

const BFrustum& BCuller::frustum() const
{
	return member.frustum;
}
const BSpace& BCuller::space()
{
	return member.space;
}

void BCuller::addNode(BNode* node)
{
	BLight* light = dynamic_cast<BLight*>(node);
	if(light)
		member.lights.append(light);
	member.nodes.append(node);
}

BNodeList& BCuller::nodes()
{
	return member.nodes;
}
BLightList& BCuller::lights()
{
	return member.lights;
}
